package com.cg.controller;


import com.cg.dto.AddQuestionDTO;
import com.cg.dto.AddUserDTO;
import com.cg.dto.SearchUserDTO;
import com.cg.entity.User;
import com.cg.result.R;
import com.cg.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author 加
 * @since 2025-01-17
 */
@RestController
@CrossOrigin
@RequestMapping("/api/user")
@Api(value = "UserController",description ="欢迎来到用户管理" ,tags = "用户管理")
public class UserController {
    @Autowired
    private IUserService userService;

    @PostMapping("/addUser")
    @ApiOperation("新增用户")
    public R addUser(AddUserDTO addUserDTO){
        return userService.addUser(addUserDTO);
    }


    @DeleteMapping("/deleteUser")
    @ApiOperation("删除用户")
    public R deleteUser(@RequestParam("userId")Long userId){
        return userService.deleteUser(userId);
    }


    @ApiOperation(value = "获取用户信息")
    @PostMapping("/getUserByCondition")
    public R<List<User>> getUserByCondition(@Validated @RequestBody SearchUserDTO searchUserDTO){
        return userService.getUserByCondition(searchUserDTO);
    }

}
